import pandas as pd
import matplotlib.pyplot as plt

# 读取CSV文件，指定列名为 'x' 和 'y'
ppform_data = pd.read_csv('spline_test4_PPform_complete.csv', header=None, names=['x', 'y'])
bspline_data = pd.read_csv('spline_test4_BSpline_complete.csv', header=None, names=['x', 'y'])

# 绘制PPForm样条插值曲线
plt.plot(ppform_data['x'], ppform_data['y'], label='PPForm Spline', color='blue')

# 绘制BSpline样条插值曲线
plt.plot(bspline_data['x'], bspline_data['y'], label='BSpline', color='red')

# 添加图例
plt.legend()

# 添加标题和标签
plt.title('Spline Interpolation Comparison')
plt.xlabel('x')
plt.ylabel('y')

# 显示网格
plt.grid(True)
# Save the plot as a PNG file
plt.savefig(f'../figure/test4.png')
# 显示图形
plt.show()